//
//  TrackMapTableViewCell.m
//  location
//
//  Created by Dongxiang Xu on 2024/5/11.
//

#import "TrackMapTableViewCell.h"

@interface TrackMapTableViewCell ()

@property (nonatomic, strong) UIButton *mapImg;
@property (nonatomic, strong) UILabel *title;
@property (nonatomic, strong) UILabel *time;


@end

@implementation TrackMapTableViewCell

- (void)prepareForReuse {
    [super prepareForReuse];
    // 重置或保持状态
}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = RealWhiteColor;
        
        _mapImg = [[UIButton alloc] initWithFrame:CGRectMake(16, 0, 42, 42)];
        _mapImg.layer.masksToBounds = YES;
        [_mapImg.layer setCornerRadius:8];
        _mapImg.backgroundColor = WhiteColor;
        [self.contentView addSubview:_mapImg];
        
        _title = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_mapImg.frame)+12, _mapImg.y, SCREEN_WIDTH-CGRectGetMaxX(_mapImg.frame)-28, 24)];
        _title.textColor = RealBlackColor;
        _title.font = REAL_MEDIUM_FONT(16);
        [self.contentView addSubview:_title];
        
        _time = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_mapImg.frame)+12, CGRectGetMaxY(_title.frame)+2, SCREEN_WIDTH-CGRectGetMaxX(_mapImg.frame)-28, 16)];
        _time.textColor = GraryLightColor;
        _time.font = DEFAULT_FONT(14);
        [self.contentView addSubview:_time];
                
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(16, CGRectGetMaxY(_time.frame)+12, SCREEN_WIDTH-32, (SCREEN_WIDTH-32)*0.3838)];
        view.backgroundColor = WhiteColor;
        view.layer.masksToBounds = YES;
        [view.layer setCornerRadius:10];
        [self.contentView addSubview:view];
        
        _imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, view.width, (SCREEN_WIDTH-32)*0.3838+3)];        
        [view addSubview:_imgView];
    }
    return self;
}

- (void)loadWithInfo:(NSMutableDictionary *)info
{
    if ([info[@"title"] containsString:@"驾车"]) {
        [_mapImg setImage:[UIImage imageNamed:@"drive"] forState:UIControlStateNormal];
    }else if ([info[@"title"] containsString:@"行程"]){
        [_mapImg setImage:[UIImage imageNamed:@"walk"] forState:UIControlStateNormal];
    }
        
    if ([info[@"title"] isKindOfClass:[NSString class]] && [info[@"title"] length]>0) {
        _title.text = [NSString stringWithFormat:@"%@",info[@"title"]];
    }else{
        _title.text = @"";
    }
    _time.text = [NSString stringWithFormat:@"%@",info[@"timeRun"]];
  
}

@end
